var CandyO = CandyO || {};
CandyO.End = function(t) {
    this.buttonStart = null ,
    this.create = function() {
        var e = ["batman", "captain", "hulk"]
          , i = Phaser.ArrayUtils.getRandomItem(e)
          , a = t.add.sprite(0, 0, "final-" + i)
          , s = Math.min(CandyO.SAFE_ZONE_WIDTH / a.width, CandyO.SAFE_ZONE_HEIGHT / a.height);
        a.scale.set(s, s),
        a.anchor.set(.5, .5),
        a.x = CandyO.SAFE_ZONE_WIDTH / 2,
        a.y = CandyO.SAFE_ZONE_HEIGHT / 2,
        this.buttonStart = t.add.button(t.world.centerX, CandyO.SAFE_ZONE_HEIGHT - 67, "button-start", this.startGameClicked, this, 0, 1, 1),
        this.buttonStart.anchor.set(.5, 0);
        var n = CandyO.Game.LeftPlayer.points > CandyO.Game.RightPlayer.points ? CandyO.Game.LeftPlayer : CandyO.Game.RightPlayer
          , o = t.add.text(t.world.centerX, 20, i + " likes " + n.name.toUpperCase(), {
            font: "bold 32px Arial",
            fill: "#ffffff",
            style: "bold",
            align: "center"
        });
        o.anchor.set(.5, 0),
        setTimeout(function() {
            CandyO.Game.yeahSound.play()
        }, 500)
    }
    ,
    this.startGameClicked = function() {
        t.state.start("Menu")
    }
}
;
var CandyO = CandyO || {};
CandyO.Menu = function(t) {
    this.leftGroup = new Array,
    this.rightGroup = new Array,
    this.buttonStart = null ,
    this.preload = function() {}
    ,
    this.create = function() {
        CandyO.Game.resetPlayers(),
        CandyO.Game.boomSound = t.add.audio("sound-boom", CandyO.Game.VOLUME),
        CandyO.Game.boomSound.allowMultiple = !0,
        CandyO.Game.laserSound = t.add.audio("sound-laser", CandyO.Game.VOLUME),
        CandyO.Game.laserSound.allowMultiple = !0,
        CandyO.Game.tomasSound = t.add.audio("sound-tomas", 1),
        CandyO.Game.tomasSound.allowMultiple = !1,
        CandyO.Game.lukasSound = t.add.audio("sound-lukas", 1),
        CandyO.Game.lukasSound.allowMultiple = !1,
        CandyO.Game.gabrieleSound = t.add.audio("sound-gabriele", 1),
        CandyO.Game.gabrieleSound.allowMultiple = !1,
        CandyO.Game.vsSound = t.add.audio("sound-vs", 1),
        CandyO.Game.vsSound.allowMultiple = !1,
        CandyO.Game.bravoSound = t.add.audio("sound-bravo", 1),
        CandyO.Game.bravoSound.allowMultiple = !1,
        CandyO.Game.correctSound = t.add.audio("sound-correct", CandyO.Game.VOLUME),
        CandyO.Game.correctSound.allowMultiple = !1,
        CandyO.Game.yeahSound = t.add.audio("sound-yeah", CandyO.Game.VOLUME),
        CandyO.Game.yeahSound.allowMultiple = !1;
        var e = t.add.sprite(CandyO.SAFE_ZONE_WIDTH / 2, 0, "separator");
        e.height = CandyO.SAFE_ZONE_HEIGHT - 80;
        var e = t.add.sprite(0, CandyO.SAFE_ZONE_HEIGHT - 80, "separator");
        e.width = CandyO.SAFE_ZONE_WIDTH;
        var i = this.createButton("tomas", CandyO.Game.tomasSound, "left");
        i.y = 10,
        this.leftGroup.push(i);
        var a = this.createButton("lukas", CandyO.Game.lukasSound, "left");
        a.y = 170,
        this.leftGroup.push(a);
        var s = this.createButton("gabriele", CandyO.Game.gabrieleSound, "left");
        s.y = 330,
        this.leftGroup.push(s);
        var i = this.createButton("tomas", CandyO.Game.tomasSound, "right");
        i.y = 10,
        this.rightGroup.push(i);
        var a = this.createButton("lukas", CandyO.Game.lukasSound, "right");
        a.y = 170,
        this.rightGroup.push(a);
        var s = this.createButton("gabriele", CandyO.Game.gabrieleSound, "right");
        s.y = 330,
        this.rightGroup.push(s),
        this.buttonStart = t.add.button(t.world.centerX, CandyO.SAFE_ZONE_HEIGHT - 67, "button-start", this.startGameClicked, this, 0, 1, 1),
        this.buttonStart.anchor.set(.5, 0),
        this.buttonStart.visible = !1;
        t.add.button(0, CandyO.SAFE_ZONE_HEIGHT - 75, "icon-fullscreen", this.fullScreenClicked, this)
    }
    ,
    this.fullScreenClicked = function() {
        t.scale.isFullScreen ? t.scale.stopFullScreen() : t.scale.startFullScreen(!1)
    }
    ,
    this.startGameClicked = function() {
        CandyO.Game.LeftPlayer.sound.onStop.addOnce(function() {
            CandyO.Game.vsSound.play()
        }),
        CandyO.Game.vsSound.onStop.addOnce(function() {
            CandyO.Game.RightPlayer.sound.play()
        }),
        CandyO.Game.RightPlayer.sound.onStop.addOnce(function() {
            t.state.start("Game")
        }),
        CandyO.Game.LeftPlayer.sound.play()
    }
    ,
    this.createButton = function(e, i, a) {
        var s = t.add.group();
        s.x = "left" == a ? 10 : CandyO.SAFE_ZONE_WIDTH - 135;
        var n = t.add.sprite(0, 0, e);
        n.inputEnabled = !0,
        n.input.useHandCursor = !0,
        "left" == a ? n.events.onInputDown.add(this.LeftPlayerSelected, this) : n.events.onInputDown.add(this.RightPlayerSelected, this),
        n.scale.set(.2, .2),
        n.name = e,
        n.assignedSound = i,
        n.useHandCursor = !0;
        var o;
        if ("left" == a)
            var o = t.add.text(135, 50, e.toUpperCase(), {
                font: "32px Arial",
                fill: "#ffffff",
                align: "left"
            });
        else {
            var o = t.add.text(-30, 50, e.toUpperCase(), {
                font: "32px Arial",
                fill: "#ffffff",
                align: "center"
            });
            o.anchor.set(1, 0)
        }
        return s.addChild(n),
        s.addChild(o),
        s
    }
    ,
    this.LeftPlayerSelected = function(e) {
        for (var i = 0; i < this.leftGroup.length; i++)
            t.add.tween(this.leftGroup[i]).to({
                alpha: .3
            }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
            t.add.tween(this.leftGroup[i].scale).to({
                x: .9,
                y: .9
            }, 100, Phaser.Easing.Sinusoidal.In, !0, 0);
        t.add.tween(e.parent).to({
            alpha: 1
        }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
        t.add.tween(e.parent.scale).to({
            x: 1,
            y: 1
        }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
        CandyO.Game.LeftPlayer.name = e.name,
        CandyO.Game.LeftPlayer.sound = e.assignedSound,
        this.CheckIfGameCanStart()
    }
    ,
    this.RightPlayerSelected = function(e) {
        for (var i = 0; i < this.rightGroup.length; i++)
            t.add.tween(this.rightGroup[i]).to({
                alpha: .3
            }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
            t.add.tween(this.rightGroup[i].scale).to({
                x: .9,
                y: .9
            }, 100, Phaser.Easing.Sinusoidal.In, !0, 0);
        t.add.tween(e.parent).to({
            alpha: 1
        }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
        t.add.tween(e.parent.scale).to({
            x: 1,
            y: 1
        }, 100, Phaser.Easing.Sinusoidal.In, !0, 0),
        CandyO.Game.RightPlayer.name = e.name,
        e.name,
        CandyO.Game.RightPlayer.sound = e.assignedSound,
        this.CheckIfGameCanStart()
    }
    ,
    this.CheckIfGameCanStart = function() {
        void 0 != CandyO.Game.LeftPlayer.name && void 0 != CandyO.Game.RightPlayer.name && (this.buttonStart.visible = !0)
    }
    ,
    this.render = function() {}
    ,
    this.update = function() {}
}
;